var RenYuan = new Vue({

    el : '#GuifanTongjilist',
    data :{

        DeptId : $("#DeptId").val(),
        DeptName : $("#DeptName").val(),
        deptId : '',

        danweilist:[],
        tongjibiao:{},


    },
    created : function() {

        this.findTongjibiao();
        this.selectDeptAll();

    },
    methods : {

        selectDeptAll : function() {
            var _this = this;

            // 单位
            $.post("../dept/findcengji_by_deptid", {
                deptid:"0",
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.danweilist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        findTongjibiao: function(){
            var _this = this;
            var mmDeptId = _this.deptId;
            if (mmDeptId==""){
                mmDeptId = _this.DeptId;
            }
            $.post("../renyuan/find_guifantongjibiao",{
                deptid : _this.deptId,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        _this.tongjibiao=ppData.resultContent;

                        _this.createTongjibiao();

                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },

        Daochu: function(){
            var _this = this;
            var mmDeptId = _this.deptId;
            if (mmDeptId==""){
                mmDeptId = _this.DeptId;
            }
            window.open("../daochu/daochu_guifantongji?deptid="+_this.deptId);
        },

        createTongjibiao: function (){
            var _this=this;
            //获取dom容器
            var myChart = echarts.init(document.getElementById('tongji'));
            option = {
                title : {
                    text: '经商办企业情况统计表',
                    subtext: ''
                },
                tooltip : {
                    trigger: 'axis'
                },
                legend: {
                    data:['纳入规范范围人数','存在经商办企业行为人数','规范对象人数','选择退出经商办企业人数','选择本人退出人数']
                },
                toolbox: {
                    show : true,
                    feature : {
                        mark : {show: true},
                        dataView : {show: true, readOnly: false},
                        magicType : {show: true, type: ['line', 'bar']},
                        restore : {show: true},
                        saveAsImage : {show: true}
                    }
                },
                grid:{
                    left:'10%',
                    bottom:'35%'
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'category',
                        data : ['总人数','上将战区正职及相应职级','中将战区副职及相应职级','少将军级正职及相应职级','少将军级副职及相应职级','大校师级正职及相应职级','大校师级副职及相应职级','上校团级正职及相应职级'],
                        axisLabel:{
                            interval:0,
                            rotate:40
                        },

                    },

                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        name:'纳入规范范围人数',
                        type:'bar',
                        data:[_this.tongjibiao.quanbu, _this.tongjibiao.shangjiangquanbu, _this.tongjibiao.zhongjiangquanbu, _this.tongjibiao.shaojiangzhengquanbu, _this.tongjibiao.shaojiangfuquanbu, _this.tongjibiao.daxiaozhengquanbu, _this.tongjibiao.daxiaofuquanbu,_this.tongjibiao.shangxiaozhengquanbu],
                       /* markPoint : {
                            data : [
                                {type : 'max', name: '最大值'},
                                {type : 'min', name: '最小值'}
                            ]
                        },
                        markLine : {
                            data : [
                                {type : 'average', name: '平均值'}
                            ]
                        }*/
                    },
                    {
                        name:'存在经商办企业行为人数',
                        type:'bar',
                        data:[_this.tongjibiao.jingshang, _this.tongjibiao.shangjiangjingshang, _this.tongjibiao.zhongjiangjingshang, _this.tongjibiao.shaojiangzhengjingshang, _this.tongjibiao.shaojiangfujingshang, _this.tongjibiao.daxiaozhengjingshang, _this.tongjibiao.daxiaofujingshang,_this.tongjibiao.shangxiaozhengjingshang],
                        /*markPoint : {
                            data : [
                                {name : '年最高', value : 182.2, xAxis: 7, yAxis: 183, symbolSize:18},
                                {name : '年最低', value : 2.3, xAxis: 11, yAxis: 3}
                            ]
                        },
                        markLine : {
                            data : [
                                {type : 'average', name : '平均值'}
                            ]
                        }*/
                    },
                    {
                        name:'规范对象人数',
                        type:'bar',
                        data:[_this.tongjibiao.tcquanbu, _this.tongjibiao.tcshangjiangquanbu, _this.tongjibiao.tczhongjiangquanbu, _this.tongjibiao.tcshaojiangzhengquanbu, _this.tongjibiao.tcshaojiangfuquanbu, _this.tongjibiao.tcdaxiaozhengquanbu, _this.tongjibiao.tcdaxiaofuquanbu,_this.tongjibiao.tcshangxiaozhengquanbu],

                    },
                    {
                        name:'存在经商办企业行为人数',
                        type:'bar',
                        data:[_this.tongjibiao.tcjingshang, _this.tongjibiao.tcshangjiangjingshang, _this.tongjibiao.tczhongjiangjingshang, _this.tongjibiao.tcshaojiangzhengjingshang, _this.tongjibiao.tcshaojiangfujingshang, _this.tongjibiao.tcdaxiaozhengjingshang, _this.tongjibiao.tcdaxiaofujingshang,_this.tongjibiao.tcshangxiaozhengjingshang],

                    },
                    {
                        name:'选择本人退出人数',
                        type:'bar',
                        data:[_this.tongjibiao.tcbenren, _this.tongjibiao.tcshangjiangbenren, _this.tongjibiao.tczhongjiangbenren, _this.tongjibiao.tcshaojiangzhengbenren, _this.tongjibiao.tcshaojiangfubenren, _this.tongjibiao.tcdaxiaozhengbenren, _this.tongjibiao.tcdaxiaofubenren,_this.tongjibiao.tcshangxiaozhengbenren],

                    },
                ]
            };


            console.log(option);

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);

        },
    },


});
